lib: Check for http_proxy being the empty string
authorMatthew Leeds <matthew.leeds@endlessm.com>
Tue, 2 Apr 2019 20:40:11 +0000 (13:40 -0700)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 2 Apr 2019 20:44:08 +0000 (20:44 +0000)
On at least one user's computer, g_getenv("http_proxy") returns the
empty string, so check for that and treat it as no proxy rather than
printing a warning.

See https://github.com/flatpak/flatpak/issues/2790

Closes: #1835
Approved by: cgwalters

src/libostree/ostree-fetcher-soup.c
src/libostree/ostree-repo-pull.c

index 3951a927f37abee5bdf1bdf6aa209f422a509133..970ac7a4b32894a1413d9e3f7daa805b20c31cfc 100644 (file)
@@ -645,7 +645,7 @@ _ostree_fetcher_constructed (GObject *object)
     }
 
   http_proxy = g_getenv ("http_proxy");
-  if (http_proxy != NULL)
+  if (http_proxy != NULL && http_proxy[0] != '\0')
     _ostree_fetcher_set_proxy (self, http_proxy);
 
   /* FIXME Maybe implement GInitableIface and use g_thread_try_new()
@@ -711,7 +711,7 @@ _ostree_fetcher_set_proxy (OstreeFetcher *self,
   SoupURI *proxy_uri;
 
   g_return_if_fail (OSTREE_IS_FETCHER (self));
-  g_return_if_fail (http_proxy != NULL);
+  g_return_if_fail (http_proxy != NULL && http_proxy[0] != '\0');
 
   proxy_uri = soup_uri_new (http_proxy);
 
index 1377ee9280b8f41069af1fbb852bef964786cc8a..5d77bc7e9806c132bfec70742c7407c12ef8a9e2 100644 (file)
@@ -3034,7 +3034,7 @@ _ostree_repo_remote_new_fetcher (OstreeRepo  *self,
                                         &http_proxy, error))
       goto out;
 
-    if (http_proxy != NULL)
+    if (http_proxy != NULL && http_proxy[0] != '\0')
       _ostree_fetcher_set_proxy (fetcher, http_proxy);
   }